import request from '@/utils/request'

// 查询巡检详情列表
export function listInspectionDetail(query) {
  return request({
    url: '/ldzl-sb/inspection/detail/list',
    method: 'get',
    params: query
  })
}

// 查询巡检详情
export function getInspectionDetail(detailId) {
  return request({
    url: '/ldzl-sb/inspection/detail/' + detailId,
    method: 'get'
  })
}

// 新增巡检详情
export function addInspectionDetail(data) {
  return request({
    url: '/ldzl-sb/inspection/detail',
    method: 'post',
    data: data
  })
}

// 修改巡检详情
export function updateInspectionDetail(data) {
  return request({
    url: '/ldzl-sb/inspection/detail',
    method: 'put',
    data: data
  })
}

// 删除巡检详情
export function delInspectionDetail(detailId) {
  return request({
    url: '/ldzl-sb/inspection/detail/' + detailId,
    method: 'delete'
  })
}

// 根据记录ID获取巡检详情
export function getDetailsByRecordId(recordId) {
  console.log("调用getDetailsByRecordId API, recordId:", recordId);
  return request({
    url: '/ldzl-sb/inspection/detail/record/' + recordId,
    method: 'get'
  }).then(response => {
    console.log("getDetailsByRecordId API响应:", response);
    return response;
  }).catch(error => {
    console.error("getDetailsByRecordId API错误:", error);
    throw error;
  });
}

// 批量提交巡检结果
export function submitInspectionResults(data) {
  return request({
    url: '/ldzl-sb/inspection/detail/batch',
    method: 'post',
    data: data
  })
} 